<template>
  <div id="RecordsTypeList">

    <el-table :data="obj.records" style="width: 100%">
      <el-table-column prop="rtName" label="类型名称"></el-table-column>
      <el-table-column prop="rtType" label="类型"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button class="el-icon-edit" circle size="mini"
            @click="handleEdit(scope.$index, scope.row)"></el-button>
          <el-button class="el-icon-delete" circle size="mini" type="danger"
            @click="handleDelete(scope.$index, scope.row)"></el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="obj.current"
      :page-sizes="[10, 50, 100, 200]"
      :page-size="10"
      layout="total, sizes, prev, pager, next, jumper"
      :total="obj.total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'RecordsTypeList',
  data() {
    return {
      obj: {},
      pagination: {
        size : 10,
        current : 1
      }
    }
  },
  methods: {
    //修改
    handleEdit(index, obj){
      console.log(index, obj);
      this.dialogFormVisible=true
    },
    //删除
    handleDelete(index, obj){
      console.log(index, obj);
      this.dialogFormVisible=true
    },
    //跳转
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.pagination.size = val
      this.paging()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.pagination.current = val
      this.paging()
    },
    paging(){
      this.$http.get('/recordsType/getRecordsTypePage', {
        params: this.pagination
      })
      .then(response => {
        console.log(response);
        this.obj = response.data.obj;
      })
      .catch(error => {
        console.error(error);
      });
    }
  },

  mounted(){
    this.paging()
  },
}
</script>

<style scoped>

</style>
